<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是使用busybox构建根文件系统的相关笔记。若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV05-03-根文件系统-02-busybox构建根文件系统">
<meta property="og:url" content="https://sumumm.github.io/post/6002bf25.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是使用busybox构建根文件系统的相关笔记。若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20221023094430613.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802193036629.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802193123425.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802193404226.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802193607270.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802194720786.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20221023101510089.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802195935357.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802200205438.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802200547756.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802200742110.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802201019929.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802202340399.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802201259187.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802202136018.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204247330.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204403666.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204519115.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204848459.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204811516.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204938481.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205240176.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205342671.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205459693.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205609274.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210116054.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210239168.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205817200.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210316413.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210342928.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210545291.png">
<meta property="article:published_time" content="2023-09-08T11:23:14.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.042Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="(ALPHA)LV05-uboot与内核">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20221023094430613.png">


<link rel="canonical" href="https://sumumm.github.io/post/6002bf25.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/6002bf25.html","path":"post/6002bf25.html","title":"LV05-03-根文件系统-02-busybox构建根文件系统"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV05-03-根文件系统-02-busybox构建根文件系统 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E6%96%87%E4%BB%B6%E5%87%86%E5%A4%87"><span class="nav-text">一、文件准备</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96%E9%80%94%E5%BE%84"><span class="nav-text">1. 源码获取途径</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E8%8E%B7%E5%8F%96%E6%BA%90%E7%A0%81%E6%96%87%E4%BB%B6"><span class="nav-text">2. 获取源码文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E6%8B%B7%E8%B4%9D%E8%A7%A3%E5%8E%8B"><span class="nav-text">3. 拷贝解压</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E7%A7%BB%E6%A4%8D"><span class="nav-text">二、根文件系统移植</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E9%85%8D%E7%BD%AE-busybox"><span class="nav-text">1. 配置 busybox </span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91%E5%99%A8%E9%85%8D%E7%BD%AE"><span class="nav-text">1.1 交叉编译器配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E5%8A%A8%E6%80%81%E7%BC%96%E8%AF%91%E9%85%8D%E7%BD%AE"><span class="nav-text">1.2 动态编译配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-vi%E7%BC%96%E8%BE%91%E5%99%A8%E9%85%8D%E7%BD%AE"><span class="nav-text">1.3 vi编辑器配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-4-Simplified-modutils%E9%85%8D%E7%BD%AE"><span class="nav-text">1.4 Simplified modutils配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-5-mdev-%E9%85%8D%E7%BD%AE"><span class="nav-text">1.5 mdev 配置</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E7%BC%96%E8%AF%91-busybox"><span class="nav-text">2. 编译 busybox </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E5%AE%89%E8%A3%85-busybox"><span class="nav-text">3. 安装 busybox </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E6%B7%BB%E5%8A%A0-lib-%E5%BA%93"><span class="nav-text">4. 添加 lib 库</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E6%8B%B7%E8%B4%9D-lib-%E5%BA%93"><span class="nav-text">4.1 拷贝 lib 库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-%E5%90%91-usr-lib-%E6%B7%BB%E5%8A%A0%E5%BA%93"><span class="nav-text">4.2 向 &#x2F;usr&#x2F;lib 添加库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-3-%E6%9F%A5%E7%9C%8B%E5%BA%93%E5%A4%A7%E5%B0%8F"><span class="nav-text">4.3 查看库大小</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E5%88%9B%E5%BB%BA%E5%85%B6%E4%BB%96%E7%9B%AE%E5%BD%95"><span class="nav-text">5. 创建其他目录</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E5%88%9D%E6%AD%A5%E6%B5%8B%E8%AF%95"><span class="nav-text">6. 根文件系统初步测试</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#6-1-%E6%8B%B7%E8%B4%9D%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-text">6.1 拷贝根文件系统</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-2-%E8%AE%BE%E7%BD%AE-bootargs"><span class="nav-text">6.2 设置 bootargs</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-3-%E9%87%8D%E5%90%AF%E5%BC%80%E5%8F%91%E6%9D%BF%E6%B5%8B%E8%AF%95"><span class="nav-text">6.3 重启开发板测试</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7-%E5%AE%8C%E5%96%84%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-text">7. 完善根文件系统</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#7-1-%E5%88%9B%E5%BB%BA-etc-init-d-rcS-%E6%96%87%E4%BB%B6"><span class="nav-text">7.1 创建 &#x2F;etc&#x2F;init.d&#x2F;rcS 文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-2-%E5%88%9B%E5%BB%BA-etc-fstab-%E6%96%87%E4%BB%B6"><span class="nav-text">7.2 创建 &#x2F;etc&#x2F;fstab 文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-3-%E5%88%9B%E5%BB%BA-etc-inittab-%E6%96%87%E4%BB%B6"><span class="nav-text">7.3 创建 &#x2F;etc&#x2F;inittab 文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-4-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E6%B5%8B%E8%AF%95"><span class="nav-text">7.4 根文件系统测试</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E7%9A%84%E5%AE%8C%E5%96%84"><span class="nav-text">三、根文件系统的完善</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-busybox-%E4%B8%AD%E6%96%87%E5%AD%97%E7%AC%A6%E6%94%AF%E6%8C%81"><span class="nav-text">1. busybox 中文字符支持</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E4%B8%AD%E6%96%87%E4%B9%B1%E7%A0%81%EF%BC%9F"><span class="nav-text">1.1 中文乱码？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-printable-string-c-%E6%96%87%E4%BB%B6%E4%BF%AE%E6%94%B9"><span class="nav-text">1.2 printable_string.c 文件修改</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-unicode-c-%E6%96%87%E4%BB%B6%E4%BF%AE%E6%94%B9"><span class="nav-text">1.3 unicode.c 文件修改</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-4-busybox-%E9%85%8D%E7%BD%AE"><span class="nav-text">1.4 busybox 配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-5-%E9%87%8D%E6%96%B0%E5%88%B6%E4%BD%9C%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-text">1.5 重新制作根文件系统</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-6-%E4%B8%AD%E6%96%87%E6%94%AF%E6%8C%81%E6%B5%8B%E8%AF%95"><span class="nav-text">1.6 中文支持测试</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E7%BB%88%E7%AB%AF%E8%B7%AF%E5%BE%84%E6%94%AF%E6%8C%81"><span class="nav-text">2. 终端路径支持</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-PS1%E5%8F%98%E9%87%8F%E4%BB%8B%E7%BB%8D"><span class="nav-text">2.1 PS1变量介绍</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-PS1%E5%8F%98%E9%87%8F%E8%AF%B4%E6%98%8E"><span class="nav-text">2.2 PS1变量说明</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#2-2-1-%E5%86%85%E7%BD%AE%E5%8F%98%E9%87%8F"><span class="nav-text">2.2.1 内置变量</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-2-2-%E9%A2%9C%E8%89%B2%E8%AE%BE%E7%BD%AE"><span class="nav-text">2.2.2 颜色设置</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-PS1%E5%8F%98%E9%87%8F%E4%BF%AE%E6%94%B9"><span class="nav-text">2.3 PS1变量修改</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/6002bf25.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV05-03-根文件系统-02-busybox构建根文件系统 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV05-03-根文件系统-02-busybox构建根文件系统
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-09-08 19:23:14" itemprop="dateCreated datePublished" datetime="2023-09-08T19:23:14+08:00">2023-09-08</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/" itemprop="url" rel="index"><span itemprop="name">02IMX6ULL平台</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/" itemprop="url" rel="index"><span itemprop="name">LV05-uboot与内核</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>9k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>33 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是使用busybox构建根文件系统的相关笔记。若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows版本</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu版本</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>      </tr>    <tr>        <td align="center">Linux开发板</td>        <td align="left">正点原子 i.MX6ULL Linux 阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="5">官方网站</td>        <td align="left"><a href="https://www.arm.com/" target="_blank">https://www.arm.com/</a></td>        <td align="left">ARM官方网站，在这里我们可以找到Cotex-Mx以及ARMVx的一些文档</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/" target="_blank">https://www.nxp.com.cn/ </a></td>        <td align="left">NXP官方网站</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxpic.org.cn/" target="_blank">https://www.nxpic.org.cn/</a></td><td align="left">NXP 官方社区</td>    </tr>    <tr>        <td align="left"><a href="https://u-boot.readthedocs.io/en/latest/" target="_blank">https://u-boot.readthedocs.io/en/latest/</a></td><td align="left">u-boot官网</td>    </tr>    <tr>        <td align="left"><a href="https://www.kernel.org/" target="_blank">https://www.kernel.org/</a></td><td align="left">linux内核官网</td>    </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="4">NXP</td>        <td align="left"><a href="https://github.com/nxp-imx" target="_blank">https://github.com/nxp-imx</a></td>        <td align="left">NXP imx开发资源GitHub组织，里边会有u-boot和linux内核的仓库</td>    </tr>    <tr>        <td align="left"><a href="https://elixir.bootlin.com/linux/latest/source" target="_blank">https://elixir.bootlin.com/linux/latest/source</a></td>        <td align="left">在线阅读linux kernel源码</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/linux-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga" target="_blank">nxp-imx/linux-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga</a></td>        <td align="left">NXP linux内核仓库tags中的rel_imx_4.1.15_2.1.0_ga</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/uboot-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga" target="_blank">nxp-imx/uboot-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga</a></td>        <td align="left">NXP u-boot仓库tags中的rel_imx_4.1.15_2.1.0_ga</td>    </tr>    <tr>        <td align="center" rowspan="2">I.MX6ULL</td>        <td align="left"><a href="https://www.nxp.com.cn/docs/en/data-sheet/IMX6ULLIEC.pdf" target="_blank">i.MX 6ULL Applications Processors for Industrial Products</a></td>        <td align="left">I.MX6ULL 芯片手册（datasheet，可以在线查看）</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/webapp/Download?colCode=IMX6ULLRM&lang_cd=zh" target="_blank">i.MX 6ULL Applications ProcessorReference Manual</a></td>        <td align="left">I.MX6ULL 参考手册（下载后才能查看，需要登录NXP官网）</td>    </tr></table>
              </div>
            </details>

<h1 id="一、文件准备"><a href="#一、文件准备" class="headerlink" title="一、文件准备"></a><font size=3>一、文件准备</font></h1><p>这里我们主要是获取 Busybox 源码。</p>
<h2 id="1-源码获取途径"><a href="#1-源码获取途径" class="headerlink" title="1. 源码获取途径"></a><font size=3>1. 源码获取途径</font></h2><p>我们可以从这里获取 Busybox 的源码：<a target="_blank" rel="noopener" href="https://busybox.net/downloads/">Index of &#x2F;downloads (busybox.net)  <i class="fa fa-external-link-alt"></i></a></p>
<h2 id="2-获取源码文件"><a href="#2-获取源码文件" class="headerlink" title="2. 获取源码文件"></a><font size=3>2. 获取源码文件</font></h2><p>我下载的是 busybox-1.22.1.tar.bz2 这个压缩包并将其存放于 ubuntu 下的共享文件夹下，路径为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/mnt/hgfs/Sharedfiles/4I.MX6U/busybox-1.22.1.tar.bz2</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20221023094430613.png" alt="image-20221023094430613" style="zoom:50%;" />

<p>下载的时候可能会非常慢，要是特别慢的话，有条件的可以科学处理一下，哈哈。</p>
<h2 id="3-拷贝解压"><a href="#3-拷贝解压" class="headerlink" title="3. 拷贝解压"></a><font size=3>3. 拷贝解压</font></h2><p>然后我们可以将这个源码文件拷贝解压到 ubuntu 中，方便后边编译，我们可以在终端执行以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cp /mnt/hgfs/Sharedfiles/4I.MX6U/busybox-1.22.1.tar.bz2  ~/5ALPHA    # 拷贝压缩包</span><br><span class="line">cd ~/5ALPHA/</span><br><span class="line">tar -xvf busybox-1.22.1.tar.bz2                                  # 解压</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802193036629.png" alt="image-20230802193036629" style="zoom:50%;" />

<p>然后我们可以得到下边这些文件（通过 ls 命令查看）：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802193123425.png" alt="image-20230802193123425" style="zoom:50%;" />

<h1 id="二、根文件系统移植"><a href="#二、根文件系统移植" class="headerlink" title="二、根文件系统移植"></a><font size=3>二、根文件系统移植</font></h1><p>根文件系统移植我们主要是使用 Busybox 来进行根文件系统的制作，前边我们已经准备好了相关的文件并解压了，我们进入 Busybox 源码的顶层目录：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cd ~/5ALPHA/busybox-1.22.1/</span><br></pre></td></tr></table></figure>

<h2 id="1-配置-busybox"><a href="#1-配置-busybox" class="headerlink" title="1. 配置 busybox "></a><font size=3>1. 配置 busybox </font></h2><p>与我们编译 Uboot、 Linux kernel 一样，我们要先对 busybox 进行默认的配置，有以下几种配置选项： </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">make defconfig    # 缺省配置，也就是默认配置选项。</span><br><span class="line">make allyesconfig # 全选配置，也就是选中 busybox 的所有功能。</span><br><span class="line">make allnoconfig  # 最小配置。</span><br></pre></td></tr></table></figure>

<p>我们一般使用<strong>默认配置</strong>即可，注意这里一定要先配置一下再编译，否则最后编译出来的根文件系统可能会少很多命令。默认配置结束后我们就可以进行一些其他的配置了，busybox 具有和 linux 内核类似的图形配置界面，我们可以通过下边的命令进入图形配置界面：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make menuconfig</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802193404226.png" alt="image-20230802193404226" style="zoom:50%;" />

<h3 id="1-1-交叉编译器配置"><a href="#1-1-交叉编译器配置" class="headerlink" title="1.1 交叉编译器配置"></a><font size=3>1.1 交叉编译器配置</font></h3><p>配置界面如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802193607270.png" alt="image-20230802193607270" style="zoom:50%;" />

<p>我们在进行根文件系统制作的时候需要先配置一下 busybox 使用的编译器，配置如下信息即可：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Busybox Configuration</span><br><span class="line">    Busybox Settings  ---&gt;</span><br><span class="line">		Build Options  ---&gt;</span><br><span class="line">			(arm-linux-gnueabihf-) Cross Compiler prefix </span><br></pre></td></tr></table></figure>

<p>配置完成后通过方向键选择 Exit 退出，并保存配置信息。</p>
<details class="folding-tag" blue><summary> 点击查看交叉编译器版本 </summary>
              <div class='content'>
              <p>我这里使用的是 gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ，交叉编译器前缀为 arm-linux-gnueabihf-，直接使用下边的命令就能看到交叉编译器的版本啦：</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">arm-linux-gnueabihf-gcc -v</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h3 id="1-2-动态编译配置"><a href="#1-2-动态编译配置" class="headerlink" title="1.2 动态编译配置"></a><font size=3>1.2 动态编译配置</font></h3><p>静态编译的话就不需要库文件，但是编译出来的库会很大。动态编译的话要求根文件系统中有库文件，但是编译出来的 busybox 会小很多。正点原子的资料中写到这里我们不能采用静态编译，因为采用静态编译的话 DNS 会出问题，无法进行域名解析，  我就暂时先按这个来啦。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Busybox Configuration</span><br><span class="line">    Busybox Settings  ---&gt;</span><br><span class="line">        Build Options  ---&gt;</span><br><span class="line">			[ ] Build BusyBox as a static binary (no shared libs)</span><br></pre></td></tr></table></figure>

<p>保证这个选项不要选中即可。</p>
<h3 id="1-3-vi编辑器配置"><a href="#1-3-vi编辑器配置" class="headerlink" title="1.3 vi编辑器配置"></a><font size=3>1.3 vi编辑器配置</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">Busybox Configuration</span><br><span class="line">    Busybox Settings  ---&gt;</span><br><span class="line">		Busybox Library Tuning  ---&gt; </span><br><span class="line">			[*] Command line editing            # 选了这个下边的选项才会出来</span><br><span class="line">			[*]   vi-style line editing commands</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="1-4-Simplified-modutils配置"><a href="#1-4-Simplified-modutils配置" class="headerlink" title="1.4 Simplified modutils配置"></a><font size=3>1.4 Simplified modutils配置</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">Busybox Configuration</span><br><span class="line">	Linux Module Utilities  ---&gt; </span><br><span class="line">		[ ] Simplified modutils</span><br><span class="line">		[*]   insmod</span><br><span class="line">        [*]   rmmod</span><br><span class="line">        [*]   lsmod</span><br><span class="line">        [*]     Pretty output</span><br><span class="line">        [*]   modprobe</span><br><span class="line">        [*]     Blacklist support</span><br><span class="line">        [*]   depmod		</span><br></pre></td></tr></table></figure>

<p>确保 Simplified modutils 这个选项没有被选中，不选中这个选项的时候下边几个选项会显示，下边几个选项是与 linux 模块加载卸载相关的，一定要选为 *。</p>
<h3 id="1-5-mdev-配置"><a href="#1-5-mdev-配置" class="headerlink" title="1.5 mdev 配置"></a><font size=3>1.5 mdev 配置</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">Busybox Configuration</span><br><span class="line">	Linux System Utilities  ---&gt; </span><br><span class="line">		[*] mdev (NEW) </span><br><span class="line">		[*]     Support subdirs/symlinks (NEW)                               </span><br><span class="line">		[*]       Support regular expressions substitutions when renaming device (NEW)</span><br><span class="line">		[*]     Support command execution at device addition/removal (NEW)</span><br><span class="line">		[*]   Support loading of firmwares (NEW) </span><br></pre></td></tr></table></figure>

<p>确保这几个选项是选中的（默认也是选中的）。</p>
<h2 id="2-编译-busybox"><a href="#2-编译-busybox" class="headerlink" title="2. 编译 busybox "></a><font size=3>2. 编译 busybox </font></h2><p>上一步配置完成就可以开始编译 busybox 了，我们可以执行如下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make</span><br></pre></td></tr></table></figure>

<p>这个比较简单，只需要一个 make 命令就可以开始编译了，这是因为我们在图形配置界面中已经配置了交叉编译器了。编译完成后，会在源码的顶层目录下生成一个 busybox 文件。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802194720786.png" alt="image-20230802194720786" style="zoom:50%;" />

<h2 id="3-安装-busybox"><a href="#3-安装-busybox" class="headerlink" title="3. 安装 busybox "></a><font size=3>3. 安装 busybox </font></h2><p>上一步只是进行了编译，我们还需要安装 busybox ，我们在终端执行：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">make install # 默认会安装到 busybox-1.22.1/_install 中</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">其实我们也可以直接指定安装的目录，避免后边拷贝相关文件的麻烦</span></span><br><span class="line">make install CONFIG_PREFIX=/home/hk/4nfs/imx_rootfs</span><br></pre></td></tr></table></figure>

<p>安装完成后会有如下提示信息（也可能没有，但不重要，只要不报错就可以了）：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20221023101510089.png" alt="image-20221023101510089" style="zoom:50%;" />

<p>若未指定安装的目录，我们会发现在 busybox 源码顶层目录下会生成一个 _install 目录，我们看一下这个目录中都有什么：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ls _install -ah</span><br></pre></td></tr></table></figure>

<p>我们会发现有如下文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802195935357.png" alt="image-20230802195935357" style="zoom:50%;" />

<p>这里边就是我们所需要的根文件系统，包含了根文件系统中所需的 shell 命令文件。</p>
<h2 id="4-添加-lib-库"><a href="#4-添加-lib-库" class="headerlink" title="4. 添加 lib 库"></a><font size=3>4. 添加 lib 库</font></h2><h3 id="4-1-拷贝-lib-库"><a href="#4-1-拷贝-lib-库" class="headerlink" title="4.1 拷贝 lib 库"></a><font size=3>4.1 拷贝 lib 库</font></h3><p>我们还需要将交叉编译工具链中的库文件拷贝到 _install 目录下，我们先进入 _install 目录下，新建一个 lib 目录：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd _install/</span><br><span class="line">mkdir lib</span><br></pre></td></tr></table></figure>

<p>lib 文件夹创建好了，库文件从哪里来呢？ <strong>lib 库文件从交叉编译器中获取</strong>。交叉编译器里面有很多的库文件，这些库文件具体是做什么的作为初学者得我肯定不知道，既然不知道那就把所有的库文件都放到我们的根文件系统中，这就意味着这样做出来的根文件系统肯定很大，但是我们现在是学习阶段，还做不了裁剪，所以这就意味着我们的eMMC需要比较大才会够用啦。</p>
<ul>
<li>交叉编译器的 arm-linux-gnueabihf&#x2F;libc&#x2F;lib 目录</li>
</ul>
<p>我们进入交叉编译器目录拷贝相关文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /home/hk/2software/gcc-linaro-4.9.4/arm-linux-gnueabihf/libc/lib # 我是放在这里的</span><br><span class="line">cp -d *so* *.a ~/5ALPHA/busybox-1.22.1/_install/lib</span><br></pre></td></tr></table></figure>

<p>拷贝完成后，根文件系统目录中的 lib 目录中的文件如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802200205438.png" alt="image-20230802200205438" style="zoom:50%;" />

<p>注意 cp 命令后面的“-d”选项表示拷贝符号链接，这里有个比较特殊的库文件： ld-linux-armhf.so.3，此库文件也是个符号链接，它会链接到库 ld-2.19-2014.08-1-git.so 上，输入以下命令查看此文件详细信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hk@ubuntu2204:~/5ALPHA/busybox-1.22.1/_install/lib$ ls ld-linux-armhf.so.3 -l</span><br><span class="line">lrwxrwxrwx 1 hk hk 24  8月  2 20:03 ld-linux-armhf.so.3 -&gt; ld-2.19-2014.08-1-git.so</span><br></pre></td></tr></table></figure>

<p>ld-linux-armhf.so.3 后面有个“-&gt;”，表示其是个软连接文件，链接到文件 ld-2.19-2014.08-1-git.so，因为其是一个“快捷方式”，因此大小只有 24B。但是， ld-linuxarmhf.so.3 不能作为符号链接，否则的话在根文件系统中执行程序无法执行。所以我们需要将实际的文件拷贝过来，方法很简单，那就是重新复制 ld-linuxarmhf.so.3，只是不复制软链接即可命令如下：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">cd ~/5ALPHA/busybox-1.22.1/_install/lib</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除 busybox-1.22.1/_install/lib 中的 ld-linux-armhf.so.3</span></span><br><span class="line">rm ld-linux-armhf.so.3</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">重新拷贝文件</span></span><br><span class="line">cd /home/hk/2software/gcc-linaro-4.9.4/arm-linux-gnueabihf/libc/lib</span><br><span class="line">cp ld-linux-armhf.so.3 /home/hk/5ALPHA/busybox-1.22.1/_install/lib</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看 busybox-1.22.1/_install/lib 中的 ld-linux-armhf.so.3 中的文件</span></span><br><span class="line">cd /home/hk/5ALPHA/busybox-1.22.1/_install/lib</span><br><span class="line">ls ld-linux-armhf.so.3 -l</span><br></pre></td></tr></table></figure>

<p>重新拷贝后，结果如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802200547756.png" alt="image-20230802200547756" style="zoom:50%;" />

<ul>
<li>交叉编译器的 arm-linux-gnueabihf&#x2F;lib</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /home/hk/2software/gcc-linaro-4.9.4/arm-linux-gnueabihf/lib</span><br><span class="line">cp *so* *.a /home/hk/5ALPHA/busybox-1.22.1/_install/lib -d</span><br></pre></td></tr></table></figure>

<p>最终我们得到的 lib 中的文件如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802200742110.png" alt="image-20230802200742110" style="zoom:50%;" />

<h3 id="4-2-向-usr-lib-添加库"><a href="#4-2-向-usr-lib-添加库" class="headerlink" title="4.2 向 &#x2F;usr&#x2F;lib 添加库"></a><font size=3>4.2 向 &#x2F;usr&#x2F;lib 添加库</font></h3><p>在 _install 的 usr 目录下创建一个名为 lib 的目录，将如下目录中的库文件拷贝到 busybox-1.22.1&#x2F;_install&#x2F;usr&#x2F;lib 目录下： </p>
 <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd /home/hk/2software/gcc-linaro-4.9.4/arm-linux-gnueabihf/libc/usr/lib</span><br><span class="line">mkdir -p /home/hk/5ALPHA/busybox-1.22.1/_install/usr/lib</span><br><span class="line">cp *so* *.a /home/hk/5ALPHA/busybox-1.22.1/_install/usr/lib -d</span><br></pre></td></tr></table></figure>

<p>完成后的 busybox-1.22.1&#x2F;_install&#x2F;usr&#x2F;lib 目录如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802201019929.png" alt="image-20230802201019929" style="zoom:50%;" />

<h3 id="4-3-查看库大小"><a href="#4-3-查看库大小" class="headerlink" title="4.3 查看库大小"></a><font size=3>4.3 查看库大小</font></h3><p>目前我们的库已经添加完毕了，可以使用“du”命令来查看一下 busybox-1.22.1&#x2F;_install&#x2F;lib 和 busybox-1.22.1&#x2F;_install&#x2F;usr&#x2F;lib 这两个目录的大小，命令如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hk@vm:~/5ALPHA/busybox-1.22.1/_install$ du ./lib ./usr/lib -sh</span><br><span class="line">57M	./lib</span><br><span class="line">67M	./usr/lib</span><br></pre></td></tr></table></figure>

<p> 可以看出lib和usr&#x2F;lib这两个文件的大小分别为57MB和67MB，加起来就是57+67&#x3D;124MB。  </p>
<h2 id="5-创建其他目录"><a href="#5-创建其他目录" class="headerlink" title="5. 创建其他目录"></a><font size=3>5. 创建其他目录</font></h2><p>在根文件系统中还需要创建其他文件夹，如 dev 、 proc 、 mnt 、  sys 、  tmp 和  root 等：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd _install/</span><br><span class="line">mkdir dev mnt proc root sys tmp var</span><br></pre></td></tr></table></figure>

<p>创建完成后，我们的根文件系统目录如下图所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802202340399.png" alt="image-20230802202340399" style="zoom:50%;" />

<p>我们刚才创建的几个都是空目录，其实可以发现我们还是少了一个 etc 目录，我们这里先不创建，一会先进行测试看看没有这个目录会有什么事情发生。</p>
<h2 id="6-根文件系统初步测试"><a href="#6-根文件系统初步测试" class="headerlink" title="6. 根文件系统初步测试"></a><font size=3>6. 根文件系统初步测试</font></h2><h3 id="6-1-拷贝根文件系统"><a href="#6-1-拷贝根文件系统" class="headerlink" title="6.1 拷贝根文件系统"></a><font size=3>6.1 拷贝根文件系统</font></h3><p>我们这里将开发板设置为从 nfs 挂载根文件系统，我们需要先复制根文件系统到 nfs 目录下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd ~/5ALPHA/busybox-1.22.1/_install/</span><br><span class="line">sudo cp -rf * ~/4nfs/imx6ull_rootfs</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802201259187.png" alt="image-20230802201259187" style="zoom:50%;" />

<h3 id="6-2-设置-bootargs"><a href="#6-2-设置-bootargs" class="headerlink" title="6.2 设置 bootargs"></a><font size=3>6.2 设置 bootargs</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">=&gt; setenv bootargs &#x27;console=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.10.101:/home/hk/4nfs/imx6ull_rootfs,proto=tcp rw ip=192.168.10.102:192.168.10.101:192.168.10.1:255.255.255.0::eth0:off init=/linuxrc&#x27;</span><br><span class="line">=&gt; saveenv</span><br></pre></td></tr></table></figure>

<h3 id="6-3-重启开发板测试"><a href="#6-3-重启开发板测试" class="headerlink" title="6.3 重启开发板测试"></a><font size=3>6.3 重启开发板测试</font></h3><p>注意我们使用的 uboot 参数与是从 tftp 加载 linux 内核和设备树（前边已经学习过了，有相关的笔记），从 nfs 挂载根文件系统。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802202136018.png" alt="image-20230802202136018" style="zoom:50%;" />

<p>这里需要注意，由于我是先搞的根文件系统，所以用的linux镜像和设备树都是正点原子出厂的，这样似乎会有驱动加载过程，但是我们又没有驱动文件，有些地方会卡很久，需要等一下，要是用我们自己移植的linux内核和设备树的话这个过程应该就很快了，另外就是有时候可能挂在不成功，这个时候就要看一下网络是否正常。从图中我们会发现，根文件系统正常挂载了，并且 ls 命令也可正常运行，但是有一个错误提示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">can&#x27;t run &#x27;/etc/init.d/rcS&#x27;: No such file or directory</span><br></pre></td></tr></table></figure>

<p>这个错误提示其实很简单，说是无法运行“ &#x2F;etc&#x2F;init.d&#x2F;rcS 这个文件，因为这个文件不存在。</p>
<h2 id="7-完善根文件系统"><a href="#7-完善根文件系统" class="headerlink" title="7. 完善根文件系统"></a><font size=3>7. 完善根文件系统</font></h2><p>首先我们需要在nfs共享目录的根文件系统中创建一个 &#x2F;etc 目录。</p>
<h3 id="7-1-创建-etc-init-d-rcS-文件"><a href="#7-1-创建-etc-init-d-rcS-文件" class="headerlink" title="7.1 创建 &#x2F;etc&#x2F;init.d&#x2F;rcS 文件"></a><font size=3>7.1 创建 &#x2F;etc&#x2F;init.d&#x2F;rcS 文件</font></h3><p>rcS 是个 shell 脚本， Linux 内核启动以后需要启动一些服务，而 rcS 就是规定启动哪些文件的脚本文件。该文件应改位于 etc&#x2F;init.d&#x2F;rcS 文件，我们创建：这个文件并添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">!/bin/sh</span></span><br><span class="line"></span><br><span class="line">PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH</span><br><span class="line">LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib</span><br><span class="line">export PATH LD_LIBRARY_PATH</span><br><span class="line"></span><br><span class="line">mount -a</span><br><span class="line">mkdir /dev/pts</span><br><span class="line">mount -t devpts devpts /dev/pts</span><br><span class="line"></span><br><span class="line">echo /sbin/mdev &gt; /proc/sys/kernel/hotplug</span><br><span class="line">mdev -s</span><br></pre></td></tr></table></figure>

<ul>
<li>第 1 行：表示这是一个 shell 脚本。</li>
<li>第 3 行：PATH 环境变量保存着可执行文件可能存在的目录，这样我们在执行一些命令或者可执行文件的时候就不会提示找不到文件这样的错误。 </li>
<li>第 4 行：LD_LIBRARY_PATH 环境变量保存着库文件所在的目录 。</li>
<li>第 5 行：使用 export 来导出上面这些环境变量，相当于声明一些“全局变量”。  </li>
<li>第 7 行：使用 mount 命令来挂载所有的文件系统，这些文件系统由文件 etc&#x2F;fstab 来指定。</li>
<li>第 8 和 9 行：创建目录&#x2F;dev&#x2F;pts，然后将 devpts 挂载到&#x2F;dev&#x2F;pts 目录中。  </li>
<li>第 11 行和第 12 行：使用 mdev 来管理热插拔设备，通过这两行， Linux 内核就可以在 &#x2F;dev 目录下自动创建设备节点。关于 mdev 的详细内容可以参考  busybox 中的 docs&#x2F;mdev.txt 文档。</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204247330.png" alt="image-20230802204247330" style="zoom:50%;" />

<p><strong>【说明】</strong></p>
<p>（1）这只是我们自己做的根文件系统中的 rcS 文件，这个是比较简单的，只有这么几行，但是 Ubuntu 或者其他大型 Linux 操作系统中的 rcS 文件，会更加的复杂，一般来说复杂的 rcS 文件也是借助其他工具创建的，比如  buildroot 等。</p>
<p>（2） etc&#x2F;init.d&#x2F;rcS 这个文件是<strong>需要有可执行文件才可以运行的</strong>。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chmod 777 rcS</span><br></pre></td></tr></table></figure>

<h3 id="7-2-创建-etc-fstab-文件"><a href="#7-2-创建-etc-fstab-文件" class="headerlink" title="7.2 创建 &#x2F;etc&#x2F;fstab 文件"></a><font size=3>7.2 创建 &#x2F;etc&#x2F;fstab 文件</font></h3><p> etc&#x2F;fstab 文件在 Linux 开机以后自动配置哪些需要自动挂载的分区，该文件中内容的格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;file system&gt; &lt;mount point&gt; &lt;type&gt; &lt;options&gt; &lt;dump&gt; &lt;pass&gt;</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>file system ：要挂载的特殊的设备，也可以是块设备，比如 &#x2F;dev&#x2F;sda 等等。</li>
<li>mount point ：挂载点。</li>
<li>type ：文件系统类型，比如  ext2 、  ext3 、  proc 、 romfs 、  tmpfs 等等。</li>
<li>options ：挂载选项，在 Ubuntu 中输入 man mount 命令可以查看具体的选项。一般使用 defaults ，也就是默认选项， defaults 包含了  rw 、  suid 、  dev 、  exec 、  auto 、  nouser 和  async 。</li>
<li>dump ：为 1 的话表示允许备份，为 0 不备份，一般不备份，因此设置为  0 。</li>
<li>pass ：磁盘检查设置，为 0 表示不检查。根目录 &#x2F; 设置为 1 ，其他的都不能设置为 1 ，其他的分区从 2 开始。一般不在 fstab 中挂载根目录，因此这里一般设置为 0 。</li>
</ul>
<p>我们创建好后添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">&lt;file system&gt; &lt;mount point&gt; &lt;<span class="built_in">type</span>&gt; &lt;options&gt; &lt;dump&gt; &lt;pass&gt;</span></span><br><span class="line">proc  /proc proc  defaults 0 0 </span><br><span class="line">tmpfs /tmp  tmpfs defaults 0 0 </span><br><span class="line">sysfs /sys  sysfs defaults 0 0 </span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204403666.png" alt="image-20230802204403666" style="zoom:50%;" />

<h3 id="7-3-创建-etc-inittab-文件"><a href="#7-3-创建-etc-inittab-文件" class="headerlink" title="7.3 创建 &#x2F;etc&#x2F;inittab 文件"></a><font size=3>7.3 创建 &#x2F;etc&#x2F;inittab 文件</font></h3><p> inittab 的详细内容可以参考 busybox 下的文件 examples&#x2F;inittab 。 init 程序会读取 etc&#x2F;inittab 这个文件， inittab 由若干条指令组成。每条指令的结构都是一样的，由以 : 分隔的 4个段组成，格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;id&gt;:&lt;runlevels&gt;:&lt;action&gt;:&lt;process&gt;</span><br></pre></td></tr></table></figure>

<p><strong>【参数说明】</strong></p>
<ul>
<li>id ：每个指令的标识符，不能重复。但是对于 busybox 的 init 来说， id 有着特殊意义。对于 busybox 而言 id 用来指定启动进程的控制 tty ，一般我们将串口或者 LCD 屏幕设置为控制 tty 。</li>
<li>runlevels ：对 busybox 来说此项完全没用，所以可以空着。</li>
<li>action ：动作，用于指定 process 可能用到的动作。</li>
</ul>
<details class="folding-tag" blue><summary> 点击查看busybox支持的动作 </summary>
              <div class='content'>
              <table>    <tr><td align="left">动作</td><td align="left">描述</td></tr>    <tr><td align="left">sysinit</td><td align="left">在系统初始化的时候 process 才会执行一次。</td></tr>    <tr><td align="left">respawn</td><td align="left">当 process 终止以后马上启动一个新的。</td></tr>    <tr><td align="left">askfirst</td><td align="left">和respawn类似，在运行 process之前在控制台上显示“Please press Enter to activate this console.”。只有用户按下 Enter 键以后才会执行 process。</td></tr>    <tr><td align="left">wait</td><td align="left">告诉init，要等待相应的进程执行完以后才能继续执行。</td></tr>    <tr><td align="left">once</td><td align="left">仅执行一次，而且不会等待 process 执行完成。</td></tr>    <tr><td align="left">restart</td><td align="left">当init重启的时候才会执行 procee。</td></tr>    <tr><td align="left">ctrlaltdel</td><td align="left">当按下ctrl+alt+del组合键才会执行 process。</td></tr>    <tr><td align="left">shutdown</td><td align="left">关机的时候执行process。</td></tr></table>
              </div>
            </details>

<ul>
<li>process ：具体的动作，比如程序、脚本或命令等。</li>
</ul>
<p>我们创建好文件后添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">etc/inittab</span></span><br><span class="line">::sysinit:/etc/init.d/rcS</span><br><span class="line">console::askfirst:-/bin/sh</span><br><span class="line">::restart:/sbin/init</span><br><span class="line">::ctrlaltdel:/sbin/reboot</span><br><span class="line">::shutdown:/bin/umount -a -r</span><br><span class="line">::shutdown:/sbin/swapoff -a</span><br></pre></td></tr></table></figure>

<ul>
<li>第 2 行，系统启动以后运行 &#x2F;etc&#x2F;init.d&#x2F;rcS 这个脚本文件。</li>
<li>第 3 行：将 console 作为控制台终端，也就是 ttymxc0。并且系统启动以后，在运行 process 之前在控制台上显示提示信息，只有用户按下 Enter 键以后才会执行 process 。  </li>
<li>第 4 行：启的话运行&#x2F;sbin&#x2F;init。  </li>
<li>第 5 行：按下 ctrl+alt+del 组合键的话就运行&#x2F;sbin&#x2F;reboot，所以ctrl+alt+del 组合键用于重启系统。  </li>
<li>第 6 行：关机的时候执行&#x2F;bin&#x2F;umount，也就是卸载各个文件系统。  </li>
<li>第 7 行：关机的时候执行&#x2F;sbin&#x2F;swapoff，也就是关闭交换分区。</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204519115.png" alt="image-20230802204519115" style="zoom:50%;" />

<h3 id="7-4-根文件系统测试"><a href="#7-4-根文件系统测试" class="headerlink" title="7.4 根文件系统测试"></a><font size=3>7.4 根文件系统测试</font></h3><p>我们直接在nfs共享目录中添加的相关文件，所以直接重启开发板就好啦。这一次就不会再有上边的哪个报错信息啦：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204848459.png" alt="image-20230802204848459" style="zoom:50%;" />

<h1 id="三、根文件系统的完善"><a href="#三、根文件系统的完善" class="headerlink" title="三、根文件系统的完善"></a><font size=3>三、根文件系统的完善</font></h1><h2 id="1-busybox-中文字符支持"><a href="#1-busybox-中文字符支持" class="headerlink" title="1. busybox 中文字符支持"></a><font size=3>1. busybox 中文字符支持</font></h2><h3 id="1-1-中文乱码？"><a href="#1-1-中文乱码？" class="headerlink" title="1.1 中文乱码？"></a><font size=3>1.1 中文乱码？</font></h3><p>我们是通过 nfs 挂载的根文件系统，我们可以在 ubuntu 的相关目录下创建一个中文命名的目录，例如：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd /home/hk/4nfs/imx6ull_rootfs</span><br><span class="line">sudo mkdir 桌面</span><br><span class="line">ls</span><br></pre></td></tr></table></figure>

<p>然后我们会看到 ubuntu 下目录详情如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204811516.png" alt="image-20230802204811516" style="zoom:50%;" />

<p>然而我们到 MobaXterm 中的串口终端，看一下根目录：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802204938481.png" alt="image-20230802204938481" style="zoom:50%;" />

<p>我们会发现并不支持中文而中中文目录显示为 ? 。老版本的 busybox 是支持中文的，但是不知道从哪个版本开始 busybox 中的 shell 命令对中文输入即显示做了限制，即使内核支持中文但在 shell 下也依然无法正确显示。这个时候就需要修改 busybox 源码了。我们先进入 busybox 源码顶层目录：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">~/5ALPHA/busybox-1.22.1/_install</span><br></pre></td></tr></table></figure>

<h3 id="1-2-printable-string-c-文件修改"><a href="#1-2-printable-string-c-文件修改" class="headerlink" title="1.2 printable_string.c 文件修改"></a><font size=3>1.2 printable_string.c 文件修改</font></h3><p>首先我们需要修改 libbb&#x2F;printable_string.c 文件，我们打开该文件后，会发现这里边只有一个 printable_string 函数，该函数中有这么几条语句：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205240176.png" alt="image-20230802205240176" style="zoom:50%;" />

<p>通过这几个语句我们知道，当字符大于 0X7F 以后就跳出去了。如果支持 UNICODE 码的话，当字符大于 0X7F 就直接输出 ? 。我们将上边的两个 if 语句进行修改：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 下边if出现在34行（将这个if注释掉） */</span></span><br><span class="line">		<span class="comment">// if (c &gt;= 0x7f)</span></span><br><span class="line">		<span class="comment">// 	break;</span></span><br><span class="line"><span class="comment">/* 下边if出现在48行 */</span></span><br><span class="line">			<span class="comment">// if (c &lt; &#x27; &#x27; || c &gt;= 0x7f)</span></span><br><span class="line">			<span class="keyword">if</span> (c &lt; <span class="string">&#x27; &#x27;</span>)</span><br><span class="line">				*d = <span class="string">&#x27;?&#x27;</span>;</span><br></pre></td></tr></table></figure>

<p>这两处修改主要是为了禁止字符大于 0X7F 以后 break 和输出 ? 。即：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205342671.png" alt="image-20230802205342671" style="zoom:50%;" />

<h3 id="1-3-unicode-c-文件修改"><a href="#1-3-unicode-c-文件修改" class="headerlink" title="1.3 unicode.c 文件修改"></a><font size=3>1.3 unicode.c 文件修改</font></h3><p>我们打开 libbb&#x2F;unicode.c 文件，然后找到 unicode_conv_to_printable2 函数，在该函数中有这么几行：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205459693.png" alt="image-20230802205459693" style="zoom:50%;" />

<p> 1022 行表示当字符大于 0X7F 以后， *d++ 就为 ? ， 1030 行和 1031 行表示，当字符大于 0X7F 以后， *d 也为 ? 。我们将其修改为以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 下边的这个三目运算符语句出现在 1022 行*/</span></span><br><span class="line">				<span class="comment">// *d++ = (c &gt;= &#x27; &#x27; &amp;&amp; c &lt; 0x7f) ? c : &#x27;?&#x27;;</span></span><br><span class="line">				*d++ = (c &gt;= <span class="string">&#x27; &#x27;</span>) ? c : <span class="string">&#x27;?&#x27;</span>;</span><br><span class="line"><span class="comment">/* 下边的这个if 出现在 1030 行*/</span></span><br><span class="line">				<span class="comment">// if (c &lt; &#x27; &#x27; || c &gt;= 0x7f)</span></span><br><span class="line">				<span class="keyword">if</span> (c &lt; <span class="string">&#x27; &#x27;</span>)</span><br><span class="line">					*d = <span class="string">&#x27;?&#x27;</span>;</span><br></pre></td></tr></table></figure>

<p>即：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205609274.png" alt="image-20230802205609274" style="zoom:50%;" />

<h3 id="1-4-busybox-配置"><a href="#1-4-busybox-配置" class="headerlink" title="1.4 busybox 配置"></a><font size=3>1.4 busybox 配置</font></h3><p>我们执行以下命令打开 busybox 的图形配置界面：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make menuconfig</span><br></pre></td></tr></table></figure>

<p>然后我们需要使能 busybox 的 unicode 编码以支持中文，配置路径如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Busybox Configuration</span><br><span class="line">    Busybox Settings  ---&gt;</span><br><span class="line">            General Configuration  ---&gt; </span><br><span class="line">                [*] Support Unicode</span><br><span class="line">                [*]   Check $LC_ALL, $LC_CTYPE and $LANG environment variables</span><br></pre></td></tr></table></figure>

<p>然后退出，一定要记得保存。</p>
<h3 id="1-5-重新制作根文件系统"><a href="#1-5-重新制作根文件系统" class="headerlink" title="1.5 重新制作根文件系统"></a><font size=3>1.5 重新制作根文件系统</font></h3><p>按照前边的步骤重新制作根文件系统即可。</p>
<h3 id="1-6-中文支持测试"><a href="#1-6-中文支持测试" class="headerlink" title="1.6 中文支持测试"></a><font size=3>1.6 中文支持测试</font></h3><p>还是之前的样子，在根文件系统新建一个卓面目录，再来看一看串口终端的情况：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210116054.png" alt="image-20230802210116054" style="zoom:50%;" />

<h2 id="2-终端路径支持"><a href="#2-终端路径支持" class="headerlink" title="2. 终端路径支持"></a><font size=3>2. 终端路径支持</font></h2><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210239168.png" alt="image-20230802210239168" style="zoom:50%;" />

<p>上边的图是 busybox 生成的根文件系统默认的情况，可以做成下图这样吗？</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802205817200.png" alt="image-20230802205817200" style="zoom:50%;" />

<h3 id="2-1-PS1变量介绍"><a href="#2-1-PS1变量介绍" class="headerlink" title="2.1 PS1变量介绍"></a><font size=3>2.1 PS1变量介绍</font></h3><p><strong>PS1命令是linux系统中的一个全局变量，用于定义用户命令行的字符显示。</strong></p>
<p>我们看一下开发板中的 PS1 变量：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210316413.png" alt="image-20230802210316413" style="zoom:50%;" />

<p>我们再看一下ubuntu中的 PS1 变量：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210342928.png" alt="image-20230802210342928" style="zoom:50%;" />

<p>看到这里，是不是就有想法了呢？我们改变这个环境变量的值不就好了吗？或者直接把ubuntu中的复制过来就可以了嘛。</p>
<h3 id="2-2-PS1变量说明"><a href="#2-2-PS1变量说明" class="headerlink" title="2.2 PS1变量说明"></a><font size=3>2.2 PS1变量说明</font></h3><p>我们以ubuntu中的 PS1 的值为例，简单了解一下都是什么意思。</p>
<h4 id="2-2-1-内置变量"><a href="#2-2-1-内置变量" class="headerlink" title="2.2.1 内置变量"></a><font size=3>2.2.1 内置变量</font></h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">\d ：# 代表日期，格式为weekday month date，例如：&quot;Mon Aug 1&quot;   </span><br><span class="line">\H ：# 完整的主机名称。   </span><br><span class="line">\h ：# 仅取主机的第一个名字。 </span><br><span class="line">\t ：# 显示时间为24小时格式，如：HH：MM：SS   </span><br><span class="line">\T ：# 显示时间为12小时格式   </span><br><span class="line">\A ：# 显示时间为24小时格式：HH：MM   </span><br><span class="line">\u ：# 当前用户的账号名称   </span><br><span class="line">\v ：# BASH的版本信息   </span><br><span class="line">\w ：# 完整的工作目录名称。家目录会以 ~代替   </span><br><span class="line">\W ：# 利用basename取得工作目录名称，所以只会列出最后一个目录 </span><br><span class="line">\# ：# 下达的第几个命令   </span><br><span class="line">\$ ：# 提示字符，如果是root时，提示符为：# ，普通用户则为：$  </span><br></pre></td></tr></table></figure>

<h4 id="2-2-2-颜色设置"><a href="#2-2-2-颜色设置" class="headerlink" title="2.2.2 颜色设置"></a><font size=3>2.2.2 颜色设置</font></h4><p>颜色代码格式：<code>\[\e[F;Bm\]</code>（其中F表示字体颜色，B表示背景颜色，其实 e 也可以用 033）：</p>
<table>
<thead>
<tr>
<th align="center">字体代码</th>
<th align="center">背景代码</th>
<th align="center">颜色</th>
</tr>
</thead>
<tbody><tr>
<td align="center">30</td>
<td align="center">40</td>
<td align="center">黑色</td>
</tr>
<tr>
<td align="center">31</td>
<td align="center">41</td>
<td align="center">红色</td>
</tr>
<tr>
<td align="center">32</td>
<td align="center">42</td>
<td align="center">绿色</td>
</tr>
<tr>
<td align="center">33</td>
<td align="center">43</td>
<td align="center">黄色</td>
</tr>
<tr>
<td align="center">34</td>
<td align="center">44</td>
<td align="center">蓝色</td>
</tr>
<tr>
<td align="center">35</td>
<td align="center">45</td>
<td align="center">紫红色</td>
</tr>
<tr>
<td align="center">36</td>
<td align="center">46</td>
<td align="center">青蓝色</td>
</tr>
<tr>
<td align="center">37</td>
<td align="center">47</td>
<td align="center">白色</td>
</tr>
</tbody></table>
<p>其实这里的语法格式跟 printf还有echo的颜色输出是一样的，都是使用的 ANSI 控制码。</p>
<h3 id="2-3-PS1变量修改"><a href="#2-3-PS1变量修改" class="headerlink" title="2.3 PS1变量修改"></a><font size=3>2.3 PS1变量修改</font></h3><p>我们在根文件系统的 &#x2F;etc 目录中新建一个 profile 文件，输入以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">!/bin/sh</span></span><br><span class="line">export HOSTNAME=imx</span><br><span class="line">export root=root</span><br><span class="line">export PS1=&quot;\[\e[36;1m$root@$HOSTNAME\e[0m: \e[34;1m\w\e[0m\]\$ &quot;</span><br><span class="line">PATH=/bin:/sbin:/usr/bin:/usr/sbin</span><br><span class="line">LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH</span><br><span class="line">export PATH LD_LIBRARY_PATH</span><br></pre></td></tr></table></figure>

<p>然后重启系统，我们会看到以下情况：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-03-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-busybox%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F/img/image-20230802210545291.png" alt="image-20230802210545291" style="zoom:50%;" />

<p><strong>【注意】</strong> PS1 变量修改的时候注意在命令提示符后边需要多加一个空格。</p>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/6002bf25.html">LV05-03-根文件系统-02-busybox构建根文件系统</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2023年09月08日 - 19:23</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/6002bf25.html" title="LV05-03-根文件系统-02-busybox构建根文件系统">https://sumumm.github.io/post/6002bf25.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/ALPHA-LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/" rel="tag"><i class="fa fa-tag"></i> (ALPHA)LV05-uboot与内核</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/1245a40a.html" rel="prev" title="LV05-03-根文件系统-03-buildroot-01-简介">
                  <i class="fa fa-angle-left"></i> LV05-03-根文件系统-03-buildroot-01-简介
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/73f002cf.html" rel="next" title="LV05-03-根文件系统-01-根文件系统简介">
                  LV05-03-根文件系统-01-根文件系统简介 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
